package com.szhmxxkj.config;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.szhmxxkj.job.UpdateDomainRecordJob;

@Configuration
public class QuartzConfigration {

	@Bean
	public JobDetail uploadTaskDetail() {
		return JobBuilder.newJob(UpdateDomainRecordJob.class).withIdentity("updateDomainRecordJob").storeDurably().build();
	}

	@Bean
	public Trigger uploadTaskTrigger() {
		//0 0 7,19 * * ?
		CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0 0 0/2 * * ?").withMisfireHandlingInstructionDoNothing();
		return TriggerBuilder.newTrigger().forJob(uploadTaskDetail()).withIdentity("updateDomainRecordJob")
				.withSchedule(scheduleBuilder).build();
	}
}
